package u10.Ejercicios.Ejercicio12;

public class Perro implements Comparable {
	private int collar;
	private float peso;
	
	public Perro(int collar, float peso){
		this.collar=collar;
		this.peso=peso;
	}
	
	public int getCollar() {
		return this.collar;
	}

	public float getPeso() {
		return this.peso;
	}
	
	public void saludar() {
		System.out.println("GUAU");
	}
		
	public String toString(){
		String cadena="";
		cadena="(P) "+this.collar+" "+this.peso;
		return cadena;
	}
	
	public boolean equals(Object o){
		boolean sol=false;
		try{
			if(this.collar==((Perro)o).collar){
				sol=true;
			}
		}
		catch(Exception e){}
		return sol;
	}

	@Override
	public int compareTo(Object o) {
		int sol=0;
		if(o instanceof Humano){
			sol=-1;
		}else if(o instanceof Gato){
			sol=1;
		}else{
			if(this.collar>((Perro)o).collar){
				sol=1;
			}else if(this.collar>((Perro)o).collar){
				sol=-1;
			}
		}
		return sol;
	}
	public int hashCode(){
		return this.collar;
	}
}
